import React, { useReducer, useEffect } from "react";
import "./indexgoods.css"
const Indexgoods = (props) => {
    let {cartAdd,indexgoods,flag}=props
    return (
        <div className="indexgoods">
            {
                indexgoods[flag] ? indexgoods[flag].content.map(item => (
                    <div className="clearfix" key={item.id}>
                        <img src={item.img} alt="" className="fl" />
                        <ul className="fr">
                            <li>{item.goodsname}</li>
                            <li>
                                <span>￥{item.price}</span>
                                <span>￥{item.market_price}</span>
                            </li>
                            <li>
                                {item.description}
                            </li>
                            <li><button onClick={()=>cartAdd(item.id)}>加购</button></li>
                        </ul>
                    </div>
                )) : null
            }

        </div>
    );
};

export default Indexgoods;
